﻿<%@ Page Language="C#" MasterPageFile="~/cms/defaultLayout.master" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="cms_default" %>

<%@ MasterType VirtualPath="~/cms/defaultLayout.master" %>
<asp:Content ID="mainContent" ContentPlaceHolderID="main" runat="server">
    <div class="content">
        <div class="buttons"><center>
                <a id="A1" class="" runat="server" href="~/cms/film"><asp:Label ID="lblFilm" runat="server"/>[Film]</a> -
                <a id="A2" class="" runat="server" href="~/cms/planning"><asp:Label ID="lblplanning" runat="server" /><b>[Planning]</b></a> -
                <a id="A3" class="" runat="server" href="~/cms/account"><asp:Label ID="lblAccount" runat="server"/>[Account]</a> -
                <a id="A4" class="" runat="server" href="~/cms/abonnement"><asp:Label ID="lblAbonnement" runat="server" />[Abonnement]</a> -
                <a id="A5" class="" runat="server" href="~/cms/zaal"><asp:Label ID="lblZaal" runat="server"/>[Zaal]</a> -
                <a id="A6" class="" runat="server" href="~/cms/vestiging"><asp:Label ID="lblVestiging" runat="server" />[Vestiging]</a> -
                <a id="A7" class="" runat="server" href="~/cms/user"><asp:Label ID="lblUser" runat="server"/>[User]</a> - 
               <a id="A8" class="" runat="server" href="~/cms/kaarten"><asp:Label ID="lblKaarten" runat="server"/>[Kaarten]</a>
                </center>
            </div>
        <p>This is "Planning" of CMS</p>
        <form id="planning_form" runat="server">
            <div class="cms_view" dir="ltr">
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="New" />&nbsp;
                 <asp:Button ID="Button2" runat="server" Text="Cancel" OnClick="Button2_Click" />&nbsp;
                <b>Selecteer Zaal: <asp:DropDownList ID="DropDownList1" DataSourceID="Zaal_select" AutoPostBack="true" DataValueField="zaalnummer" DataTextField="zaalnummer" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" runat="server"></asp:DropDownList>
                     </b><br />
                <br />
                <asp:GridView ID="PlanningGridView" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="Planning_SelectedIndexChanged" DataSourceID="Planning_Select" DataKeyNames="planning_id" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Both">
                    <AlternatingRowStyle BackColor="#CCCCCC"></AlternatingRowStyle>
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" ButtonType="Button"></asp:CommandField>
                        <asp:BoundField DataField="naam" HeaderText="Bioscoop Naam" SortExpression="naam"></asp:BoundField>
                        <asp:BoundField DataField="film" HeaderText="Film Naam" SortExpression="film"></asp:BoundField>
                        <asp:CheckBoxField DataField="dried" HeaderText="3D" SortExpression="dried"></asp:CheckBoxField>
                        <asp:BoundField DataField="zaalzaalnummer" HeaderText="Zaalnummer" SortExpression="zaalzaalnummer"></asp:BoundField>
                        <asp:BoundField DataField="tijd" HeaderText="Tijd" SortExpression="tijd"></asp:BoundField>
                        <asp:BoundField DataField="datum" HeaderText="Datum" SortExpression="datum"></asp:BoundField>
                    </Columns>
                    <FooterStyle BackColor="#CCCCCC"></FooterStyle>

                    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White"></HeaderStyle>

                    <PagerStyle HorizontalAlign="Center" BackColor="#999999" ForeColor="Black"></PagerStyle>

                    <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White"></SelectedRowStyle>

                    <SortedAscendingCellStyle BackColor="#F1F1F1"></SortedAscendingCellStyle>

                    <SortedAscendingHeaderStyle BackColor="#808080"></SortedAscendingHeaderStyle>

                    <SortedDescendingCellStyle BackColor="#CAC9C9"></SortedDescendingCellStyle>

                    <SortedDescendingHeaderStyle BackColor="#383838"></SortedDescendingHeaderStyle>
                </asp:GridView>
                <br />
                <hr />
                <br />

                <asp:DetailsView ID="PlanningDetailsOverview" runat="server" DataSourceID="PlanningDetails" CellPadding="4" ForeColor="#333333" GridLines="Horizontal"
                    OnItemInserting="PlanningDetailsOverview_ItemInserting"
                    OnItemInserted="PlanningDetailsOverview_ItemInserted"
                    OnItemUpdating="PlanningDetailsOverview_ItemUpdating"
                    OnItemUpdated="PlanningDetailsOverview_ItemUpdated"
                    OnItemDeleting="PlanningDetailsOverview_ItemDeleting"
                    OnItemDeleted="PlanningDetailsOverview_ItemDeleted"
                    AutoGenerateRows="False">
                    <AlternatingRowStyle BackColor="White"></AlternatingRowStyle>

                    <CommandRowStyle BackColor="#C5BBAF" Font-Bold="True"></CommandRowStyle>

                    <EditRowStyle BackColor="#7C6F57"></EditRowStyle>
                    <InsertRowStyle BackColor="#669999" />
                    <FieldHeaderStyle BackColor="#D0D0D0" Font-Bold="True"></FieldHeaderStyle>
                    <Fields>
                        <asp:BoundField DataField="planning_id" HeaderText="planning_id" ReadOnly="True" InsertVisible="False" SortExpression="planning_id"></asp:BoundField>
                        <asp:TemplateField HeaderText="Zaal nummer" SortExpression="zaalzaalnummer">
                            <EditItemTemplate>
                                <asp:Label runat="server" Text='<%# Bind("zaalzaalnummer") %>' ID="lblZaalPlan"></asp:Label><br />
                                <asp:DropDownList ID="Zaal_drop" runat="server" DataSourceID="Zaal" DataTextField="zaalnummer" DataValueField="zaalnummer" OnDataBound="Zaal_drop_DataBound"></asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="Zaal_drop" runat="server" DataSourceID="Zaal" DataTextField="zaalnummer" DataValueField="zaalnummer"></asp:DropDownList>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label runat="server" Text='<%# Bind("zaalzaalnummer") %>' ID="lblZaalNummer"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Bioscoop ID" SortExpression="zaalbioscoopbioscoop_id">
                            <EditItemTemplate>
                                <asp:Label runat="server" Text='<%# Bind("zaalbioscoopbioscoop_id") %>' ID="lblBiosPlan"></asp:Label><br />
                                <asp:DropDownList ID="Bioscoop_drop" runat="server" DataSourceID="Bios" DataTextField="naam" DataValueField="bioscoop_id" OnDataBound="Bioscoop_drop_DataBound"></asp:DropDownList>

                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="Bioscoop_drop" runat="server" DataSourceID="Bios" DataTextField="naam" DataValueField="bioscoop_id"></asp:DropDownList>

                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label runat="server" Text='<%# Bind("zaalbioscoopbioscoop_id") %>' ID="lblBiosID"></asp:Label>

                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Tijd" SortExpression="tijd">
                            <EditItemTemplate>
                                <asp:TextBox runat="server" Text='<%# Bind("tijd") %>' ID="txtTijd" TextMode="Time"></asp:TextBox>
                                Format: hh:mm
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtTijd" ValidationExpression="\b(0[0-9]|1[0-9]|2[0-3])(\:)(0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])\b" ErrorMessage="Vul een geldige tijd in."></asp:RegularExpressionValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox runat="server" Text='<%# Bind("tijd") %>' ID="txtTijd" TextMode="Time"></asp:TextBox>
                                Format: hh:mm
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtTijd" ValidationExpression="\b(0[0-9]|1[0-9]|2[0-3])(\:)(0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])\b" ErrorMessage="Vul een geldige tijd in."></asp:RegularExpressionValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label runat="server" Text='<%# Bind("tijd") %>' ID="lblTijd"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Datum" SortExpression="datum">
                            <EditItemTemplate>
                                <asp:TextBox runat="server" Text='<%# Bind("datum") %>' ID="txtDatum" TextMode="Date"></asp:TextBox>
                                <%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="txtDatum" runat="server" ValidationExpression="^([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])\/([2][01]|[1][6-9])\d{2}(\s([0-1]\d|[2][0-3])(\:[0-5]\d){1,2})?$" ErrorMessage="Vul een geldige datum in. (maand/dag/jaar)"></asp:RegularExpressionValidator>--%>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox runat="server" Text='<%# Bind("datum") %>' ID="txtDatum" TextMode="Date"></asp:TextBox>
                                <%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="txtDatum" runat="server" ValidationExpression="^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[2][0]\d{2})$|^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[2][0]\d{2}\s([0-1]\d|[2][0-3])\:[0-5]\d\:[0-5]\d)$" ErrorMessage="Vul een geldige datum in. (dag/maand/jaar)"></asp:RegularExpressionValidator>--%>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label runat="server" Text='<%# Bind("datum") %>' ID="lblDatum"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="3D" SortExpression="dried">
                            <EditItemTemplate>
                                <asp:CheckBox runat="server" Checked='<%# Bind("dried") %>' ID="Drie_D"></asp:CheckBox>

                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:CheckBox runat="server" Checked='<%# Bind("dried") %>' ID="Drie_D"></asp:CheckBox>

                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox runat="server" Checked='<%# Bind("dried") %>' Enabled="false" ID="Drie_D"></asp:CheckBox>

                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Film ID" SortExpression="filmfilm_id">
                            <EditItemTemplate>
                                <asp:Label runat="server" Text='<%# Bind("filmfilm_id") %>' ID="lblFilmPlan"></asp:Label><br />
                                <asp:DropDownList ID="Film_drop" runat="server" DataSourceID="Films" DataTextField="naam" DataValueField="film_id" OnDataBound="Film_drop_DataBound"></asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="Film_drop" runat="server" DataSourceID="Films" DataTextField="naam" DataValueField="film_id"></asp:DropDownList>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label runat="server" Text='<%# Bind("filmfilm_id") %>' ID="lblFilmID"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:CommandField ShowInsertButton="True" ShowEditButton="True" ShowDeleteButton="True" ButtonType="Button"></asp:CommandField>
                    </Fields>
                    <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White"></FooterStyle>

                    <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White"></HeaderStyle>

                    <PagerStyle HorizontalAlign="Center" BackColor="#666666" ForeColor="White"></PagerStyle>

                    <RowStyle BackColor="#E3EAEB"></RowStyle>
                </asp:DetailsView>



                <%--   <asp:DropDownList ID="Film_drop" Runat="server" DataSourceID="Films" DataTextField="naam" DataValueField="film_id"></asp:DropDownList>

                     <asp:DropDownList ID="Bioscoop_drop" Runat="server" DataSourceID="Bios" DataTextField="naam" DataValueField="bioscoop_id"></asp:DropDownList>

                     <asp:DropDownList ID="Zaal_drop" Runat="server" DataSourceID="Zaal" DataTextField="zaalnummer" DataValueField="zaalnummer"></asp:DropDownList>--%>

                <asp:SqlDataSource ID="Films" runat="server" ConnectionString='<%$ ConnectionStrings:debioscoopConnectionString %>' SelectCommand="SELECT [film_id], [naam] FROM [film]"></asp:SqlDataSource>
                <asp:SqlDataSource ID="Bios" runat="server" ConnectionString='<%$ ConnectionStrings:debioscoopConnectionString %>' SelectCommand="SELECT [bioscoop_id], [naam] FROM [bioscoop]"></asp:SqlDataSource>
                <asp:SqlDataSource ID="Zaal" runat="server" ConnectionString='<%$ ConnectionStrings:debioscoopConnectionString %>' SelectCommand="SELECT [zaalnummer] FROM [zaal]"></asp:SqlDataSource>
                
                <asp:EntityDataSource ID="Zaal_select" runat="server" ConnectionString="name=debioscoopEntities" DefaultContainerName="debioscoopEntities" EnableFlattening="False" EntitySetName="zaals" EntityTypeFilter="zaal" Select="it.[zaalnummer]"></asp:EntityDataSource>


                <asp:SqlDataSource ID="Planning_Select" runat="server" ConnectionString='<%$ ConnectionStrings:debioscoopConnectionString %>' SelectCommand="SELECT planning.planning_id, bioscoop.naam, film.naam AS film, planning.dried, planning.zaalzaalnummer, planning.tijd, planning.datum FROM film INNER JOIN planning ON film.film_id = planning.filmfilm_id INNER JOIN zaal ON planning.zaalbioscoopbioscoop_id = zaal.bioscoopbioscoop_id AND planning.zaalzaalnummer = zaal.zaalnummer INNER JOIN bioscoop ON zaal.bioscoopbioscoop_id = bioscoop.bioscoop_id WHERE planning.zaalzaalnummer = @zaalnummer">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropDownList1" PropertyName="SelectedValue" Name="zaalnummer"></asp:ControlParameter>
                    </SelectParameters>
                </asp:SqlDataSource>

                <asp:EntityDataSource ID="PlanningDetails" runat="server"
                    ConnectionString="name=debioscoopEntities"
                    DefaultContainerName="debioscoopEntities"
                    EnableDelete="True"
                    EnableFlattening="False"
                    EnableInsert="True"
                    EnableUpdate="True"
                    EntitySetName="plannings"
                    EntityTypeFilter="planning" Where="it.planning_id = @planning_id">
                    <WhereParameters>
                        <asp:ControlParameter ControlID="PlanningGridView" PropertyName="SelectedValue" Name="planning_id" Type="Int32"></asp:ControlParameter>
                    </WhereParameters>
                </asp:EntityDataSource>

                <%--<asp:SqlDataSource ID="PlanningDetails1" runat="server" ConflictDetection="CompareAllValues" 
                    ConnectionString='<%$ ConnectionStrings:debioscoopConnectionString %>' 
                    DeleteCommand="DELETE FROM [planning] WHERE [planning_id] = @original_planning_id AND [zaalzaalnummer] = @original_zaalzaalnummer AND [zaalbioscoopbioscoop_id] = @original_zaalbioscoopbioscoop_id AND [tijd] = @original_tijd AND [datum] = @original_datum AND [filmfilm_id] = @original_filmfilm_id AND (([dried] = @original_dried) OR ([dried] IS NULL AND @original_dried IS NULL))" 
                    InsertCommand="PlanningDetailsOverview_ItemInserting" 
                    OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [planning] WHERE ([planning_id] = @planning_id)" 
                    UpdateCommand="UPDATE [planning] SET [zaalzaalnummer] = @zaalzaalnummer, [zaalbioscoopbioscoop_id] = @zaalbioscoopbioscoop_id, [tijd] = @tijd, [datum] = @datum, [filmfilm_id] = @filmfilm_id, [dried] = @dried WHERE [planning_id] = @original_planning_id AND [zaalzaalnummer] = @original_zaalzaalnummer AND [zaalbioscoopbioscoop_id] = @original_zaalbioscoopbioscoop_id AND [tijd] = @original_tijd AND [datum] = @original_datum AND [filmfilm_id] = @original_filmfilm_id AND (([dried] = @original_dried) OR ([dried] IS NULL AND @original_dried IS NULL))">
                    <DeleteParameters>
                        <asp:Parameter Name="original_planning_id" Type="Int32"></asp:Parameter>
                        <asp:Parameter Name="original_zaalzaalnummer" Type="Int32"></asp:Parameter>
                        <asp:Parameter Name="original_zaalbioscoopbioscoop_id" Type="Int32"></asp:Parameter>
                        <asp:Parameter DbType="Time" Name="original_tijd"></asp:Parameter>
                        <asp:Parameter DbType="Date" Name="original_datum"></asp:Parameter>
                        <asp:Parameter Name="original_filmfilm_id" Type="Int32"></asp:Parameter>
                        <asp:Parameter Name="original_dried" Type="Boolean"></asp:Parameter>
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="zaalzaalnummer" Type="Int32"></asp:Parameter>
                        <asp:Parameter Name="zaalbioscoopbioscoop_id" Type="Int32"></asp:Parameter>
                        <asp:Parameter DbType="Time" Name="tijd"></asp:Parameter>
                        <asp:Parameter DbType="Date" Name="datum"></asp:Parameter>
                        <asp:Parameter Name="filmfilm_id" Type="Int32"></asp:Parameter>
                        <asp:Parameter Name="dried" Type="Boolean"></asp:Parameter>
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="PlanningGridView" PropertyName="SelectedValue" Name="planning_id" Type="Int32"></asp:ControlParameter>
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="zaalzaalnummer" Type="Int32"></asp:Parameter>
                        <asp:Parameter Name="zaalbioscoopbioscoop_id" Type="Int32"></asp:Parameter>
                        <asp:Parameter DbType="Time" Name="tijd"></asp:Parameter>
                        <asp:Parameter DbType="Date" Name="datum"></asp:Parameter>
                        <asp:Parameter Name="filmfilm_id" Type="Int32"></asp:Parameter>
                        <asp:Parameter Name="dried" Type="Boolean"></asp:Parameter>
                        <asp:Parameter Name="original_planning_id" Type="Int32"></asp:Parameter>
                        <asp:Parameter Name="original_zaalzaalnummer" Type="Int32"></asp:Parameter>
                        <asp:Parameter Name="original_zaalbioscoopbioscoop_id" Type="Int32"></asp:Parameter>
                        <asp:Parameter DbType="Time" Name="original_tijd"></asp:Parameter>
                        <asp:Parameter DbType="Date" Name="original_datum"></asp:Parameter>
                        <asp:Parameter Name="original_filmfilm_id" Type="Int32"></asp:Parameter>
                        <asp:Parameter Name="original_dried" Type="Boolean"></asp:Parameter>
                    </UpdateParameters>
                </asp:SqlDataSource>--%>
            </div>
        </form>
        <div class="clearDiv"></div>
    </div>
</asp:Content>
